package com.example.wallpaperapp.ui.activity;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.content.Intent;
import android.media.Image;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;

import com.example.wallpaperapp.R;
import com.example.wallpaperapp.adapter.HomeComAdapter;
import com.example.wallpaperapp.base.BaseActivity;
import com.example.wallpaperapp.bean.HomeImageRecyclerViewBean;
import com.example.wallpaperapp.utils.RecyclerViewSpacesItemDecoration;
import com.example.wallpaperapp.utils.ToastUtil;

import java.util.ArrayList;
import java.util.List;

import static com.mob.MobSDK.getContext;

public class CompilationsActivity extends BaseActivity {
    private RecyclerView recyclerView;
    private RecyclerView near_recyclerview;
    private List<HomeImageRecyclerViewBean> list = new ArrayList<>();
    private ImageView back;
    HomeComAdapter homeComAdapter;
    private String[] img_list;


    @Override
    protected int initLayout() {
        return R.layout.activity_compilations;
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @Override
    protected void initView() {
        back = (ImageView) findViewById(R.id.ad_back);
        recyclerView = findViewById(R.id.home_com_recycler);
        list.add(new HomeImageRecyclerViewBean(new String[]{"https://sjbz-fd.zol-img.com.cn/t_s208x312c5/g5/M00/03/0B/ChMkJljbcQyIR_B7AAD2vwSwgWMAAbLGgEcXJQAAPbX503.jpg","https://sjbz-fd.zol-img.com.cn/t_s208x312c5/g5/M00/03/07/ChMkJljbJWqIJfFpAADQQP5kbIgAAbKJwFcFqIAANBY663.jpg", "https://sjbz-fd.zol-img.com.cn/t_s208x312c5/g5/M00/00/03/ChMkJ1fJV3aIXRi1AAyIXXpQJUMAAU-EABsBMgADIh1529.jpg","https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=766710956,441418603&fm=26&gp=0.jpg","https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=1616808580,294494888&fm=26&gp=0.jpg","https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1170275275,2081648301&fm=26&gp=0.jpg,https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=588019164,1017593987&fm=15&gp=0.jpg"}));
        list.add(new HomeImageRecyclerViewBean(new String[]{"https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=588019164,1017593987&fm=15&gp=0.jpg","https://sjbz-fd.zol-img.com.cn/t_s208x312c5/g5/M00/03/07/ChMkJljbJWqIJfFpAADQQP5kbIgAAbKJwFcFqIAANBY663.jpg", "https://sjbz-fd.zol-img.com.cn/t_s208x312c5/g5/M00/00/03/ChMkJ1fJV3aIXRi1AAyIXXpQJUMAAU-EABsBMgADIh1529.jpg","https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=766710956,441418603&fm=26&gp=0.jpg","https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=1616808580,294494888&fm=26&gp=0.jpg","https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1170275275,2081648301&fm=26&gp=0.jpg"}));

//        list.add(new HomeImageRecyclerViewBean(new int[]{R.drawable.image0, R.drawable.img_1, R.drawable.img_3, R.drawable.img_4, R.drawable.img_5, R.drawable.img_5}));
//        list.add(new HomeImageRecyclerViewBean(R.drawable.img_4));
//        list.add(new HomeImageRecyclerViewBean(R.drawable.img_10));
//        list.add(new HomeImageRecyclerViewBean(R.drawable.img_5));

//        img_list = new int[]{R.drawable.image0, R.drawable.img_1, R.drawable.img_3, R.drawable.img_4, R.drawable.img_5, R.drawable.img_5};

        HomeComAdapter homeComAdapter = new HomeComAdapter(getContext(),list);

        recyclerView.setAdapter(homeComAdapter);

        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        recyclerView.addItemDecoration(new RecyclerViewSpacesItemDecoration(RecyclerViewSpacesItemDecoration.TOP_DECORATION, 20));
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });


        homeComAdapter.setOnItemClickListener(new HomeComAdapter.OnItemClickListener() {

            @Override
            public void onItemClicked(int position, View view) {

//                Intent intent = new Intent(CompilationsActivity.this,Activity_preview.class);
//                Bundle bundle = new Bundle();
//                bundle.putIntArray("key", new int[]{R.drawable.image0, R.drawable.img_2, R.drawable.img_3, R.drawable.img_4, R.drawable.img_5, R.drawable.img_6});
//                intent.putExtra("img",bundle);
                img_list = list.get(position).getImage_url_list();
                Activity_preview.startActivity_preview_list(CompilationsActivity.this, list.get(position).getImage_url(), img_list);
                ToastUtil.makeText(CompilationsActivity.this, "点击了第" + list.get(position).toString() + "条");
//                Intent intent_1 = new Intent();
//                //Intent传递参数
//                intent_1.putExtra("activity", 1);
//                intent_1.setClass(CompilationsActivity.this, Activity_preview.class);
//                startActivity(intent_1);
            }
        });


    }

    @Override
    protected void initData() {

    }
}